package com.ellecity06.cwhiskymall.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.ellecity06.common.ktx.load
import com.ellecity06.common.viewholder.ViewBindingHolder
import com.ellecity06.cwhiskymall.bean.response.AppMenuSettingRespone
import com.ellecity06.cwhiskymall.bean.response.ClassifyResponse
import com.ellecity06.cwhiskymall.databinding.ItemClassifyTopBinding
import com.ellecity06.cwhiskymall.databinding.ItemHomeCategoryBinding

/**
 * @author joe
 * @time
 * @des 分类顶部
 */
class ClassifyTopAdapter :
    BaseQuickAdapter<ClassifyResponse, ViewBindingHolder<ItemClassifyTopBinding>>() {

    var pos = 0
    override fun onBindViewHolder(
        holder: ViewBindingHolder<ItemClassifyTopBinding>,
        position: Int,
        item: ClassifyResponse?
    ) {
        holder.binding.title.text = item?.categoryName
        holder.binding.ivClassify.load(context, item?.categoryImage)
        holder.binding.rlImgBg.isSelected = position == pos
        holder.binding.title.isSelected = position == pos
        holder.binding.title.textSize = if (position == pos) 14f else 12f
    }

    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): ViewBindingHolder<ItemClassifyTopBinding> {
        val view = ItemClassifyTopBinding.inflate(LayoutInflater.from(context), parent, false)
        return ViewBindingHolder(view)
    }

    fun notifyPos(pos: Int) {
        this.pos = pos
        notifyDataSetChanged()
    }
}